package com.jason.hadoop.bean;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class WordBean implements WritableComparable {

    private Integer num;

    @Override
    public int compareTo(Object o) {
        WordBean wordBean = (WordBean) o;
        int number = wordBean.getNum().intValue();
        int num = this.num.intValue();
        if ( num> number) {
            return 1;
        } else if (num < number) {
            return  -1;
        }
        return 0;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(num);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.num = dataInput.readInt();
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }
}
